


/**
 * @author  Dr. Zahid Anwar
 */
public class Recipe {
    private String name;
    private int price;
    private int amtTea;
    private int amtMilk;
    private int amtSugar;
    private int amthotwater;
    
    /**
     * Creates a default recipe for the Tea maker.
     */
    public Recipe() {
    	this.name = "";
    	this.price = 0;
    	this.amtTea = 0;
    	this.amtMilk = 0;
    	this.amtSugar = 0;
    	this.amthotwater = 0;
    }
    
    /**
	 * @return   Returns the amthotwater.
	 */
    public int getAmthotwater() {
		return amthotwater;
	}
    /**
	 * @param amthotwater   The amthotwater to set.
	 */
    public void setAmthotwater(String hotwater) throws RecipeException {
    	int amthotwater = 0;
    	try {
    		amthotwater = Integer.parseInt(hotwater);
    	} catch (NumberFormatException e) {
    		throw new RecipeException("Units of hotwater must be a positive integer");
    	}
		if (amthotwater >= 0) {
			this.amthotwater = amthotwater;
		} else {
			throw new RecipeException("Units of hotwater must be a positive integer");
		}
	}
    /**
	 * @return   Returns the amtTea.
	 */
    public int getAmtTea() {
		return amtTea;
	}
    /**
	 * @param amtTea   The amtTea to set.
	 */
    public void setAmtTea(String Tea) throws RecipeException {
    	int amtTea = 0;
    	try {
    		amtTea = Integer.parseInt(Tea);
    	} catch (NumberFormatException e) {
    		throw new RecipeException("Units of Tea must be a positive integer");
    	}
		if (amtTea >= 0) {
			this.amtTea = amtTea;
		} else {
			throw new RecipeException("Units of Tea must be a positive integer");
		}
	}
    /**
	 * @return   Returns the amtMilk.
	 */
    public int getAmtMilk() {
		return amtMilk;
	}
    /**
	 * @param amtMilk   The amtMilk to set.
	 */
    public void setAmtMilk(String milk) throws RecipeException{
    	int amtMilk = 0;
    	try {
    		amtMilk = Integer.parseInt(milk);
    	} catch (NumberFormatException e) {
    		throw new RecipeException("Units of milk must be a positive integer");
    	}
		if (amtMilk >= 0) {
			this.amtMilk = amtMilk;
		} else {
			throw new RecipeException("Units of milk must be a positive integer");
		}
	}
    /**
	 * @return   Returns the amtSugar.
	 */
    public int getAmtSugar() {
		return amtSugar;
	}
    /**
	 * @param amtSugar   The amtSugar to set.
	 */
    public void setAmtSugar(String sugar) throws RecipeException {
    	int amtSugar = 0;
    	try {
    		amtSugar = Integer.parseInt(sugar);
    	} catch (NumberFormatException e) {
    		throw new RecipeException("Units of sugar must be a positive integer");
    	}
		if (amtSugar >= 0) {
			this.amtSugar = amtSugar;
		} else {
			throw new RecipeException("Units of sugar must be a positive integer");
		}
	}
    /**
	 * @return   Returns the name.
	 */
    public String getName() {
		return name;
	}
    /**
	 * @param name   The name to set.
	 */
    public void setName(String name) {
    	if(name != null) {
    		this.name = name;
    	}
	}
    /**
	 * @return   Returns the price.
	 */
    public int getPrice() {
		return price;
	}
    /**
	 * @param price   The price to set.
	 */
    public void setPrice(String price) throws RecipeException{
    	int amtPrice = 0;
    	try {
    		amtPrice = Integer.parseInt(price);
    	} catch (NumberFormatException e) {
    		throw new RecipeException("Price must be a positive integer");
    	}
		if (amtPrice >= 0) {
			this.price = amtPrice;
		} else {
			throw new RecipeException("Price must be a positive integer");
		}
	} 
    
    /**
     * Returns the name of the recipe.
     * @return String
     */
    public String toString() {
    	return name;
    }

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Recipe other = (Recipe) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

}
